package com.teen9g.infoplatformserver.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.teen9g.PageQueryDTO.PlaygroundPageQueryDTO;
import com.teen9g.entity.Playground;
import com.teen9g.userVO.PlaygroundUserVO;
import com.teen9g.vo.PlaygroundVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

@Mapper
public interface PlaygroundMapper extends BaseMapper<Playground> {
    List<PlaygroundVO> selectByPage(PlaygroundPageQueryDTO playgroundPageQueryDTO);

    @Select("select * from playground order by playground_view desc limit #{topCount}")
    List<Playground> selectTopTotalViewPlaygrounds(@Param("topCount") int topCount);

    @Update("update playground set playground_view = playground_view + #{increment} where content_id = #{contentId}")
    void updateViewCount(@Param("contentId") Integer contentId, @Param("increment") Integer increment);

    @Update("update playground set playground_comment_count = playground_comment_count + #{updateCount} where content_id = #{relatedId}")
    void updateCommentCount(@Param("relatedId") Integer relatedId, @Param("updateCount") Integer updateCount);

    List<PlaygroundUserVO> selectByPageUser(PlaygroundPageQueryDTO playgroundPageQueryDTO);
}
